package com.example.eurekaclient_provider2.controller;

import com.example.eurekaclient_provider2.domain.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName:Hystrix
 * Package:com.bjpowernode.springcloud.controller
 * Description: 描述信息
 *
 * @date:2021/12/20 14:55
 * @author:动力节点
 */
@RestController
@RequestMapping("/provider/hystrix")
public class HystrixController {

    /**
     * 模拟运行时异常
     * @return
     */
    @GetMapping("/01")
    public R hystrix01(){
        int i=1/0;
        return R.ok();
    }

    /**
     * 模拟超时异常
     * @return
     */
    @GetMapping("/02")
    public R hystrix02() throws InterruptedException {
        Thread.sleep(5000);
        return R.ok();
    }

    @GetMapping("/03/{id}")
    public R hystrix03(@PathVariable Integer id){

        if(id <= 0){
            int i=1/0;
            return R.err(1,"报错了...");
        }

        return R.ok();

    }
}
